package net.sourceforge.zmanim.util;

import java.util.Calendar;

public class CalendarImpl implements ICalendar {
    Calendar calender = Calendar.getInstance();
    DateDTO date = new DateDTO();

    private void ClearAndSetDate(){
        calender.clear();
        calender.setTime(date);
    }
    public CalendarImpl(Calendar calender) {
        this.calender = calender;
    }

    public CalendarImpl(Calendar calender, DateDTO date) {
        this.calender = calender;
        this.date = date;
    }

    public DateDTO getDate() {
        ClearAndSetDate();
        return date;
    }

    public int getDay() {
        ClearAndSetDate();
                return calender.get(Calendar.DAY_OF_MONTH);
    }

    public int getMonth() {
        ClearAndSetDate();
                return calender.get(Calendar.MONTH);
    }

    public int getYear() {
        ClearAndSetDate();
                 return calender.get(Calendar.YEAR);
    }

    public int getDayOfWeek() {
        ClearAndSetDate();
                return calender.get(Calendar.DAY_OF_WEEK);
    }

    public int getDayOfYear() {
        ClearAndSetDate();
                return calender.get(Calendar.DAY_OF_YEAR);
    }

    public void setDate(DateDTO date) {
        this.date = date;
    }

    public void setDay(int day) {
        calender.set(Calendar.DAY_OF_MONTH, day);
    }

    public void setMonth(int month) {
        calender.set(Calendar.MONTH, month);
    }

    public void setYear(int year) {
        calender.set(Calendar.YEAR, year);
    }

    public void setHour(int hour) {
        calender.set(Calendar.HOUR_OF_DAY, hour);
    }

    public void setMinute(int minute) {
        calender.set(Calendar.MINUTE, minute);
    }

    public void setSecond(int second) {
        calender.set(Calendar.SECOND, second);
    }

    public void setMillisecond(int millisecond) {
        calender.set(Calendar.MILLISECOND, millisecond);
    }
}
